#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QWidget>
#include <QPushButton>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // 作业需求：一个按钮开关控制页面的展示与关闭

    // 1、创建一个需要展示的视图
    QWidget *showWidget = new QWidget;

    // 2、创建开关按钮
    QPushButton *openBtn = new QPushButton("Open", this);
    openBtn->move(100, 100);

    connect(openBtn, &QPushButton::clicked, this, [=](){

        if(openBtn->text() == QString("Open")) {
            openBtn->setText("Close");
            showWidget->show();
        } else {
            openBtn->setText("Open");
            showWidget->close();
        }
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

